import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'
import store from './store'
//引入elementui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
//引入md编辑器
import VueMarkdownEditor from '@kangc/v-md-editor';
import '@kangc/v-md-editor/lib/style/base-editor.css';
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js';
import '@kangc/v-md-editor/lib/theme/style/vuepress.css'
import Prism from 'prismjs';
//md预览插件
import VMdPreview from '@kangc/v-md-editor/lib/preview';
import '@kangc/v-md-editor/lib/style/preview.css';
import githubTheme from '@kangc/v-md-editor/lib/theme/github.js';
import '@kangc/v-md-editor/lib/theme/style/github.css';
// highlightjs
import hljs from 'highlight.js';

VMdPreview.use(githubTheme, {
  Hljs: hljs,
});

Vue.use(VMdPreview);
// var tokenkey = localStorage.getItem('token')
//挂载axios
Vue.prototype.axios=axios;
axios.defaults.baseURL="http://localhost:8088";
// axios.defaults.headers.common['token']=tokenkey
axios.interceptors.request.use(function (request){
  //
  if (localStorage.getItem('token')) {
    request.headers.token = localStorage.getItem('token');
  }
  console.log("request!");
  return request
},function(error){
  return Promise.reject(error)
})
axios.interceptors.response.use(function (response) {
  // 对响应数据做点什么
  // response.setHeader("Access-Control-Allow-Headers","*");
  console.log("允许跨域");
  return response;
}, function (error) {
  // 对响应错误做点什么
  return Promise.reject(error);
})
// axios.defaults.withCredentials=true;
VueMarkdownEditor.use(vuepressTheme, {
  Prism,
});
Vue.use(VueMarkdownEditor);

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
